<template>
    <div class="collapse-item-content">
        <component :is="cName"
          ref="comp"
          @change="handleChange"
          @changeRadio="handleRadioChange"
          :value="value"
          :objId="objId"
          :reloadTreeFlag="reloadSmallTreeFlag"
          :resultsymbolData="resultsymbolData"
          @changeOperators="handleOperatorsChange"
          @changeCodeOperators="handleCodeOperatorsChange"
          @changeConditions="handleConditionsChange"

          @changeConditions2="handleConditions2Change"
          @changeDates="handleDatesChange"
          @checkTree="handleTreeChange"
          @getChecked="getChecked"
          :showSmallTree="showSmallTree"
          :dateIsShow="dateIsShow"
          :inputIsShow="inputIsShow">
        </component>
    </div>
</template>

<script>
// 根据业务类型显示对应下拉框
// 业务类型为代码，则动态组件名称为Codes
// 业务类型为业务对象下属机构，则动态组件名称为SpeccialObj
// 业务类型为业务对象下属非机构选项，则动态组件名称为CommonObj
import Codes from "./businessType/codes/code.vue";
import SpecialObj from "./businessType/businessObj/specialObj.vue";
import CommonObj from "./businessType/businessObj/commonObj.vue";
export default {
  name: "componentSelect",
  components: {
    Codes,
    SpecialObj,
    CommonObj
  },
  props: {
    cName: {
      type: String,
      default: ""
    },
    value: [Object, Array, String, Number],
    objId: String,
    dateIsShow: {
      type: Boolean,
      default: false
    },
    inputIsShow: {
      type: Boolean,
      default: false
    },
    resultsymbolData: {
      type: Array,
      default() {
        return []
      }
    },
    showSmallTree: {
      type: Boolean,
      default: false
    },
    reloadSmallTreeFlag: {
      type: Boolean,
      default: true
    }
  },
  methods: {
    handleChange(type, val) {
      // eslint-disable-next-line
      console.log("handleChange:::", type, val);
    },
    handleRadioChange(val) {
      this.$emit("changeRadio", val);
    },
    handleOperatorsChange(val) {
      this.$emit("changeOperators", val);
    },
    handleConditionsChange(val) {
      this.$emit("changeConditions", val);
    },
    handleConditions2Change(val) {
      this.$emit("changeConditions2", val);
    },
    handleDatesChange(val) {
      this.$emit("changeDates", val);
    },
    handleTreeChange(val) {
      this.$emit("checkTree", val);
    },
    getChecked(val, checkedKeys, checkedNodes, halfCheckedKeys, halfCheckedNodes) {
      this.$emit("getChecked", checkedKeys, checkedNodes, halfCheckedKeys, halfCheckedNodes)
    },
    handleCodeOperatorsChange(val) {
      this.$emit("changeCodeOperators", val);
    }
  }
};
</script>
